package dao.impl;

import dao.IUserDao;
import model.User;
import org.apache.ibatis.session.SqlSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @aythor:侯仪澳
 * @data:2022/8/1
 */
@Repository
public class UserDao implements IUserDao {

    @Autowired
    private SqlSession sqlSession;
    String url = "dao.IUserDao.";
    //查询登录用户
    @Override
    public List<User> queryAllUser(User user) {
        return sqlSession.selectList(url + "queryAllUser" , user);
    }

    //查询一个用户
    @Override
    public User queryOneUser(User user) {
        return sqlSession.selectOne(url + "queryOneUser" , user);
    }

    //注册用户
    @Override
    public int insertOneUser(User user) {
        return sqlSession.insert(url + "insertOneUser",user);
    }

    //查用户名和手机号是否存在
    @Override
    public User checkUser(User user) {
        return sqlSession.selectOne(url + "checkUser",user);
    }

    //修改用户余额
    @Override
    public int updateUserMoney(User user) {
        return sqlSession.update(url + "updateUserMoney",user);
    }

    @Override
    public int addUserMoney(User user) {
        return sqlSession.update(url + "addUserMoney",user);
    }

    //修改用户信息
    @Override
    public int updateUserInfo(User user) {
        return sqlSession.update(url + "updateUserInfo",user);
    }
}
